package demo

import (
	"log"

	"github.com/ClickHouse/clickhouse-go/v2"
	"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
)

var (
	addr   = "localhost:9000"
	dbName = "suricata_db"
	user   = "stash_user"
	pass   = "ck_user_password"
)

func Conn() (driver.Conn, error) {
	// 连接ClickHouse
	conn, err := clickhouse.Open(&clickhouse.Options{
		Addr: []string{addr},
		Auth: clickhouse.Auth{
			Database: dbName,
			Username: user,
			Password: pass,
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	return conn, nil
}
